import request from "@/utils/request";

//登入
export function login(form) {
  var user = JSON.stringify(form);
  return request({
    url: "/user/login",
    method: "post",
    data:user,
    headers:{
      "Content-Type":"application/json"
    }
  });
}

//用户(登录者)信息
export function getInfo() {
  return request({
    url: "/user/info",
    method: "get"
    // params: { token }
  });
}

//登出
export function logout() {
  return request({
    url: "/user/logout",
    method: "post"
  });
}

export function user_statics() {
  return request({
    url: "/user/statics",
    method: "post"
  });
}

//获取所有用户数据
export function getList(params,config) {
  return request({
    url: '/user/users',
    method: 'get',
    params,
    ...config
  })
}

//删除用户数据
export function delUser(index){
  return request({
    url: '/user/delete',
    method:'post',
    params:{
      index: index
    }
  })
}

//更新用户数据
export function updateUser(form){
  var user = JSON.stringify(form);
  return request({
    url: '/user/update',
    method:'post',
    data:user,
    headers: {
      "Content-Type":"application/json"
    }
  })
}

//查询某位用户的数据
export function queryUser(formInline){
  var user = JSON.stringify(formInline);
  return request({
    url: '/user/query',
    method:'post',
    data:user,
    headers:{
      "Content-Type":"application/json"
    }
  })
}

//添加某位用户的数据
export function addUser(form){
  var user = JSON.stringify(form);
  return request({
    url: '/user/insert',
    method:'post',
    data:user,
    headers: {
      "Content-Type":"application/json"
    }
  })
}

//获取在线数量
export function getOnline() {
  return request({
    url: '/user/online',
    method: 'get'
  })
}

//获取总用户数量
export function getTotal() {
  return request({
    url: '/user/total',
    method: 'get'
  })
}

//获取今日新增用户数量
export function getTdy(time) {
  return request({
    url: '/user/tdy',
    method: 'get',
    params:{time}
  })
}

export function getNew(time) {
  return request({
    url: '/user/new',
    method: 'get',
    params:{time}
  })
}
